package com.lykj.llw.box.ui.activity

import android.content.Intent
import android.net.Uri
import android.os.Binder
import android.os.Bundle
import android.view.View
import com.blankj.utilcode.util.ClipboardUtils
import com.gyf.immersionbar.BarHide
import com.gyf.immersionbar.ImmersionBar
import com.lykj.lib_base.base.BaseActivity
import com.lykj.lib_base.internal.extfun.clickWithTrigger
import com.lykj.lib_base.internal.utils.PackageUtils
import com.lykj.lib_base.internal.utils.ToastUtils
import com.lykj.llw.box.databinding.ActMyKefuBinding

/**
 * ================================================
 * 我的客服页面
 * ================================================
 *
 * @author gosha
 * @date 2023/10/16-17:03
 */
class MyKeFuActivity : BaseActivity() {
    lateinit var binding: ActMyKefuBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActMyKefuBinding.inflate(layoutInflater)
        setContentView(binding.root)
        initUI()
        initData()
        setListener()
    }

    override fun onResume() {
        super.onResume()

        ImmersionBar.with(this).transparentBar()
            .statusBarDarkFont(true) //状态栏字体是深色，不写默认为亮色
            .navigationBarDarkIcon(true)
            .hideBar(BarHide.FLAG_HIDE_NAVIGATION_BAR)
            .navigationBarEnable(false)
            .init()
    }

    override fun initUI() {
        binding.titleBar.tvTitle.text = "我的客服"
        binding.titleBar.tvRightOption.visibility = View.INVISIBLE
    }

    override fun initData() {
    }

    override fun setListener() {
        binding.titleBar.ivBack.clickWithTrigger {
            finish()
        }

        binding.tvContractUs.clickWithTrigger {
            if (PackageUtils.checkApk(this, "com.tencent.mobileqq") || PackageUtils.checkApk(
                    this,
                    "com.tencent.tim"
                )
            ) {
                startActivity(
                    Intent(
                        Intent.ACTION_VIEW,
                        Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=2719218701&version=1")
                    )
                )
            } else {
                ToastUtils.showShort(this, "QQ未安装")
            }
        }

        binding.tvCopy.clickWithTrigger {
            ClipboardUtils.copyText("87互娱game")

            ToastUtils.showShort(this, "已复制到剪贴板")
        }

        binding.tvBtnContract.clickWithTrigger {
            val intent = Intent(this, CommonWebViewActivity::class.java)
            intent.putExtra("title", "智能客服")
            intent.putExtra(
                "url",
                "https://tb.53kf.com/code/client/249b9773fb35caabc5f89a5c6ce0847c7/1"
            )
            startActivity(intent)
        }
    }

    override fun onDestroy() {
        super.onDestroy()
    }
}